package nl.windgazer.arachne.pages;

import nl.windgazer.arachne.components.yql.YQLFlickrPhotos;
import nl.windgazer.arachne.components.yql.YQLFlickrPhotoset;
import nl.windgazer.arachne.components.yql.YQLFlickrRecentPhotos;
import nl.windgazer.arachne.services.yql.YQLConduit;

import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SetupRender;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.json.JSONObject;

public class YQLTest {

	//Injects and Persists

	@Inject
	private YQLConduit yc;

	//Properties and Parameters

	@SuppressWarnings("unused")
	@Property
	private JSONObject aliasq;

	@SuppressWarnings("unused")
	@Property
	private JSONObject yqlq;

	//Components

	@SuppressWarnings("unused")
	@Component(id = "pc", parameters = {})
	private YQLFlickrPhotos _pcComponent;

	@SuppressWarnings("unused")
	@Component(id = "pcr", parameters = {"user=literal:windgazer","start=20","number=4"})
	private YQLFlickrRecentPhotos _pcrComponent;

	@SuppressWarnings("unused")
	@Component(id = "pca", parameters = {"user=literal:windgazer","title=literal:Roadtrip!!!"})
	private YQLFlickrPhotoset _pcaComponent;
	
	//Events

	@SetupRender
	void retreiveQueries() {
		aliasq = yc.jsonByAlias("windgazer", "flickrprofile", "user", "windgazer");
		yqlq = yc.jsonByQuery("SELECT * FROM flickr.people.findbyusername WHERE username='windgazer'");
	}

	//Other (check for business-logic, it should not remain here)

}
